#define Enable

using UnityEditor;

namespace CGF
{
    public class TextureImportFormat : AssetPostprocessor
    {
        //支持填写目录或文件名
        string[] IgnoreList =
        {
            ""
        };
        
#if Enable  
        //图片导入时自动压缩
        void OnPreprocessTexture()
        {
            TextureImporter importer = (TextureImporter)assetImporter;
            // 关键：只有在“导入设置缺失”（即第一次导入或从未修改过）时才应用规则
            if (importer.importSettingsMissing)
            {
                for (int i = 0; i < IgnoreList.Length; i++)
                {
                    if (!string.IsNullOrEmpty(IgnoreList[i]) && importer.assetPath.Contains(IgnoreList[i])) return;
                }
                importer.spriteImportMode = SpriteImportMode.Single;
                importer.SaveAndReimport();
            }
        }
#endif
    }
}